﻿/*!	@file	r_raytrace_buffer.h
	@brief	raytraceバッファ
Copyright (c) 2011 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _R_RAYTRACE_BUFFER_H_
#define _R_RAYTRACE_BUFFER_H_

#include "../math/r_math_vector3.h"
#include "../math/r_math_matrix34.h"
#include "../alloc/r_alloc_new_delete.h"
#include "r_raytrace_allocator.h"

namespace r{
	namespace raytrace{
		//! 最終的に柔軟なバッファ構成にしたいが、まずは固定で
		/*!
		*/
		struct BufferPixel{
			r_f32		r;
			r_f32		g;
			r_f32		b;
			r_f32		z;
			r_ui32		n;		//!< 試行回数
		};
		class Buffer{
		public:
			RALLOC_PLACEMENT_NEW_DELETE ( r::raytrace::AllocatorData()() )
		public:
			//! コンストラクタ
			Buffer( r_ui32 w, r_ui32 h )
			: width( w )
			, height( h ){
			}
			//! デストラクタ
			~Buffer( void ){
			}
		public:
			//! 横幅を取得する
			inline r_ui32		getWidth( void )const{
				return width;
			}
			//! 縦幅を取得する
			inline r_ui32		getHeight( void )const{
				return height;
			}
		public:
			//! バッファをクリアする
			void	clearBuffer( void );
			//! 特定ピクセルに値を設定する
			inline void			setPixel( r_ui32 x, r_ui32 y, const BufferPixel& pix ){
			}
			//! 特定ピクセルの値を取得する
			inline const BufferPixel	getPixel( r_ui32 x, r_ui32 y ){
				BufferPixel buff;
				return buff;
			}
		protected:
		private:
			//! バッファサイズ
			r_ui32				width;
			//! バッファサイズ
			r_ui32				height;
		};
	}
}

#endif // _R_RAYTRACE_BUFFER_H_

